<?php

class deleteEmploymentContractsAction extends sfAction
{

    private $employmentContractService;

    public function getEmploymentContractService()
    {
        if (is_null($this->employmentContractService)) {
            $this->employmentContractService = new EmploymentContractService();
            $this->employmentContractService->setEmploymentContractDao(new EmploymentContractDao());
        }
        return $this->employmentContractService;
    }

    public function execute($request)
    {
        $empNumber = $request->getParameter('empNumber');
        $toBeDeletedEmploymentContractIds = $request->getParameter('chkListRecord');

        if (!empty($toBeDeletedEmploymentContractIds)) {
            $this->getEmploymentContractService()->deleteEmploymentContract($toBeDeletedEmploymentContractIds);
            $this->getUser()->setFlash('employmentcontract.success', __(TopLevelMessages::DELETE_SUCCESS));
            $this->redirect('tlupim/viewEmploymentContractList?empNumber=' . $empNumber);
        }
    }

}

